<?php
/**
 * 	NKApp
 *
 * @category   NKApp
 * @package    NKApp
 * @copyright  Copyright (c) 2009 Nathan Keyes
 * @author $Author: nkeyes $
 * @version    $Id: AuditLog.php 178 2009-11-07 16:11:38Z nkeyes $
 */
 
class Bushido_DbTable_AuditLog extends Bushido_Db_Table_Abstract
{
	protected $_name = 'audit_log';
	protected $_niceName = 'Audit Log';
	protected $_sequence = true;
	
	protected $_referenceMap = array
	(
		'User' => array
		(
			'columns' => 'bushido_user_id',
			'refTableClass' => 'Bushido_DbTable_User',
			'refColumns' => 'bushido_user_id'
		)
	);
	
	
	/**
	 * (non-PHPdoc)
	 * @see library/Bushido/Table/Bushido_Table_Abstract#getSearchableFields()
	 */
	public function getSearchableFields()
	{
	}
	
	/**
	 * (non-PHPdoc)
	 * @see library/Bushido/Db/Table/Bushido_Db_Table_Abstract#_setFieldDetails()
	 */
	protected function _setFieldDetails()
	{
		//user_id
		$this->_metaaudit['bushido_user_id']['fieldDetails'] = array
		(
			'options' => array
			(
				'label' => 'User:',
				'required' => true,
				'promptMessage' => 'Please choose a User.'
			) 
		);
		
		//timestamp
		$this->_metaaudit['timestamp']['fieldDetails'] = array
		(
			'options' => array
			(
				'label' => 'Time Stamp:',
				'required' => true,
				'promptMessage' => 'Please enter a time stamp.'
			) 
		);
		
		//type
		$this->_metaaudit['type']['fieldDetails'] = array
		(
			'options' => array
			(
				'label' => 'Type:',
				'required' => true,
				'promptMessage' => 'Please enter a type.'
			) 
		);
		
		//table
		$this->_metaaudit['table']['fieldDetails'] = array
		(
			'options' => array
			(
				'label' => 'Table:',
				'required' => true,
				'promptMessage' => 'Please enter a table name.'
			) 
		);
		
		//details
		$this->_metaaudit['details']['fieldDetails'] = array
		(
			'options' => array
			(
				'label' => 'Details:',
				'required' => true,
				'promptMessage' => 'Please enter details.'
			) 
		);
	}
	
	/**
	 * (non-PHPdoc)
	 * @see library/Bushido/Table/Bushido_Table_Abstract#getDisplayValue()
	 */
	public static function getDisplayValue(Zend_Db_Table_Row_Abstract $row, $context = null)
	{
		$user = $row->findParentDefault_Model_DbTable_User();
		
		return $row->type . ' ' . $row->table_name . ' ' . Bushido_Db_Table::getDisplayValue($user) . ' ' . $row->timestamp;
	}
}